<template>
  <div class="product">
    <n-image
        :src="detail.mainImgUrl"
        :preview-src="detail.mainImgUrl"
        :fallback-src="ImgDefault"
        width="80"
        height="80"
        class="product__image"
    />
    <div class="product__info">
      <div class="product__name">
        {{ detail.goodsName }}
      </div>
      <div class="product__id">
        产品ID： {{ detail.id }}
      </div>
    </div>
  </div>
</template>

<script setup>
import {NImage} from 'naive-ui'
import ImgDefault from '@/assets/images/img-default.png'

const props = defineProps({
  detail: {
    type: Object,
    default: () => ({})
  },
})
</script>

<style scoped lang="scss">
@import 'src/assets/styles/var';

.product {
  display: flex;
  align-items: center;

  &__image {
    flex: none;
  }

  &__info {
    margin-left: 10px;
    display: flex;
    padding-bottom: 3px;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
  }

  &__name--text {
    width: v-bind(titleWidth);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: initial;
    line-height: normal;
    cursor: pointer;
    color: $primaryColor;

    &:hover {
      opacity: 0.9;
    }
  }

  &__brand,
  &__id {
    color: #999999;
    font-size: 12px;
  }
}

.default-pic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: #f5f7fa;
}
</style>
